import request from "@/utils/request";

// 商品分类category的增删改查
export const getCategory = (params) => request.get("/category/", { params });

// 一维数组的结构
export const getCategoryAll = (params) =>
  request.get("/category/all/", { params });

export const addCategory = (data) => request.post("/category/", data);

export const editCategory = (data) =>
  request.patch(`/category/${data.id}/`, data);

export const deleteCategory = (data) => request.delete(`/category/${data.id}/`);

// 和商品相关的增删改查的接口
export const getProduct = (params) => request.get("/product/", { params });

// 获取商品的详情
export const getProductById = (id) => request.get(`/product/${id}/`);

export const addProduct = (data) => request.post("/product/", data);

export const editProduct = (data) =>
  request.patch(`/product/${data.id}/`, data);

export const deleteProduct = (data) => request.delete(`/product/${data.id}/`);

// 仅仅获取商品id  支持分页
export const getProductIds = (params) => request.get("/product/id", { params });

// 根据id数组 批量获取商品详情 传递数据的形式 ： {group:[20001,2000,20003]}
export const getProductByGroup = (data) =>
  request.post("/product/group/", data);

export const uploadProductImage = (data) =>
  request.post("/product-image/", data);

export const deleteProductImage = (data) =>
  request.delete(`/product-image/${data.id}/`);
